<?php

/*
 * CLASE ENTIDAD ROL 
 * Autor: Luis Rojas
 * Version: 1.0
 * Fecha Creacion: 27/08/2013
 * Fecha Modificación: 27/08/2013
 */
require_once '../Control/CsCtrlData.php';
require_once '../Data/CsConexion.php';
class CsRol extends CsConexion {
    var $tabla;
    var $atributo;
    var $dato;
    var $ncol;
    var $nllave;
    
    function  CsRol(){
        $this->tabla = "rol";
        $this->atributo[0]="rolcod";
        $this->atributo[1]="rolnom";
        $this->ncol=2;
        $this->nllave=1;
    }
    
    function GuardarDato($cn){
        $objcontrol = new CsCtrlData();
        $sql = $objcontrol->Insert($this->tabla, $this->dato, $this->ncol);
        return $this->Transaccionx($sql,$cn);
    }
    
    function ActualizarDato($cn){
        $objcontrol = new CsCtrlData();
        $sql = $objcontrol->Update($this->tabla, $this->dato, $this->atributo, $this->ncol, $this->nllave);
        return $this->Transaccionx($sql, $cn);
    }
    
    function EliminarDato($cn){
        $objcontrol = new CsCtrlData();
        $sql = $objcontrol->Delete($this->tabla, $this->dato, $this->atributo, $this->nllave);
        return $this->Transaccionx($sql, $cn);
    }
    
    function TraerDatos(){
        $sql = "select * from $this->tabla";
        return $this->Transaccion($sql);
    }
    
    function MenuxRol(){
        $valor = $this->dato;
        $sql = "SELECT menu.mencod,menu.mennom,menu.menlin FROM rol inner join rol_menu on rol.rolcod = rol_menu.rolcod inner join menu on rol_menu.mencod = menu.mencod where rol.rolcod = $valor[0]";
        return $this->Transaccion($sql);
    }
    
    function SubmenuxRol(){
        $valor = $this->dato;
        $sql = "SELECT submenu.subcod, submenu.subnom,submenu.sublin FROM rol inner join rol_sub on rol.rolcod = rol_sub.rolcod inner join submenu on rol_sub.subcod = submenu.subcod where rol.rolcod = $valor[0] and submenu.mencod = $valor[1]";
        return $this->Transaccion($sql);
    }
}

?>
